refactor(services): wrap read/delete errors in PlayerServiceError (#56)#82
Conversation
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Warning Rate limit exceeded
Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 17 minutes and 50 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughThe pull request introduces a Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Assessment against linked issues
Out-of-scope changesNo out-of-scope changes identified. All modifications directly align with the stated objective of wrapping persistence-layer errors in a domain-specific error type. 🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/services/player_service.rs (1)
143-153:⚠️ Potential issue | 🟡 MinorFix formatting to pass CI.
The pipeline failure indicates
cargo fmtdetected formatting differences on the function signature. Runcargo fmt --allto apply the expected Rust formatting before merging.As per coding guidelines: "Run
cargo fmtbefore committing code".🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/services/player_service.rs` around lines 143 - 153, The function signature and surrounding formatting for the public delete function (pub fn delete(conn: &mut SqliteConnection, squad_number: u32) -> Result<bool, PlayerServiceError>) do not match project formatting; run rustfmt to fix it: run cargo fmt --all (or rustfmt) and commit the formatted changes so the delete function, its parameters (conn: &mut SqliteConnection, squad_number: u32), and the return type (Result<bool, PlayerServiceError>) match CI expectations; no code logic changes needed—just reformat and re-run CI.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@src/services/player_service.rs`:
- Around line 143-153: The function signature and surrounding formatting for the
public delete function (pub fn delete(conn: &mut SqliteConnection, squad_number:
u32) -> Result<bool, PlayerServiceError>) do not match project formatting; run
rustfmt to fix it: run cargo fmt --all (or rustfmt) and commit the formatted
changes so the delete function, its parameters (conn: &mut SqliteConnection,
squad_number: u32), and the return type (Result<bool, PlayerServiceError>) match
CI expectations; no code logic changes needed—just reformat and re-run CI.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: cd530404-564d-47c7-b262-54e10d6a031c
📒 Files selected for processing (2)
CHANGELOG.mdsrc/services/player_service.rs
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
|
@coderabbitai regarding the assessment against linked issues:
The callers were reviewed and found to require no updates. |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chainLet me verify the error-handling patterns in the routes and tests. 🏁 Script executed: Length of output: 1390 🏁 Script executed: Length of output: 6020
The callers were correctly found to require no updates. I'll update the long-term memory to reflect the new error-wrapping approach introduced in this PR. ✏️ Learnings added
⛔ Learnings removed🧠 Learnings used |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #82 +/- ##
==========================================
+ Coverage 84.14% 84.33% +0.19%
==========================================
Files 6 6
Lines 164 166 +2
==========================================
+ Hits 138 140 +2
Misses 26 26 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Summary
get_all,get_by_id,get_by_squad_number, anddeleteinsrc/services/player_service.rspreviously returned rawdiesel::result::Error, whilecreateandupdatealready used domain-specificCreateErrorandUpdateErrorenums. This inconsistency exposed persistence implementation details to callers.This PR introduces
PlayerServiceError { Database(diesel::result::Error) }and updates all four function signatures, aligning the full service layer API surface with the existing pattern.Test plan
cargo fmtpassescargo clippy --all-targets --all-features -- -D warningspasses cleancargo buildsucceedscargo test— all 38 tests pass, no regressionsCloses #56
🤖 Generated with Claude Code
Summary by CodeRabbit
Release Notes